<template>
  <div class="g-header">
    <div class="g-header-content g-padding-x pl-[32px]">
      <div class="g-header-left">
        <GLink to="https://gitcode.com/">
          <div class="g-header-logo"></div>
        </GLink>
        <div class="g-header-logo-small h-[28px]">
          <GLink to="https://gitcode.com/">
            <GIcon name="gt-logo-picture" size="28" />
          </GLink>
        </div>
        <NewsMenus class="g-header-menu ml-[32px]" />
        <GIcon v-show="isNewsDetail && showMenu" class="menu_mb" name="gt-line-list" size="16px" @click="openMenu" />
      </div>
    </div>
  </div>
</template>
<script lang='ts' setup>
import NewsMenus from './NewsMenus.vue'
const open = ref(false)
const showMenu = ref(false)
const route= useRoute()

const isNewsDetail = computed(()=>{
  return route.name === `news-detail`
})
//打开目录
const openMenu = () => {
  open.value = !open.value
  emitEvent('openMenu', { open: open.value })
}

//关闭目录
addEmitEvent('closeMenu', (close) => {
  open.value = close
})


//移动端显示目录
addEmitEvent('showMobileMenu', (close) => {
  showMenu.value = close
})
</script>
<style scoped lang="scss">
.g-header {
  min-height: 56px;

  &-content {
    background-color: #fff;
    top: 0;
    width: 100%;
    z-index: 6;
    position: fixed;
    border-bottom: 1px solid #F1F1F8;
  }

  &-left {
    display: flex;
    align-items: center;
    height: 56px;
  }

  &-logo {
    display: inline-block;
    width: 121px;
    height: 56px;
    background: url(https://cdn-static.gitcode.com/static/images/gitcode-logo-dark.png) no-repeat;
    background-size: contain;
    vertical-align: middle;
    background-position: 0 center;

    &-small {
      display: none;
    }
  }
}

@media screen and (min-width: 1024px) {
  .menu_mb {
    display: none
  }


}

@media screen and (max-width: 1024px) {
  .menu_mb {
    display: block;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg) !important;
  }
}

@media screen and (max-width: 768px) {
  .g-header-logo {
    display: none;
  }

  .g-header-logo-small {
    display: inline-block;
  }


}
</style>
